<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>后台管理系统</title>
  <link rel="stylesheet" href="{{ static_url('layui/css/layui.css') }}">
  <link rel="stylesheet" href="{{ static_url('css/global.css')}}">
  <link rel="stylesheet" href="{{static_url('icheck/minimal/red.css')}}">
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">

  {% include 'temp_nav.html' %}
  
  <div class="layui-body">
    <!-- 内容主体区域 -->
    <div style="padding: 15px;">
        <fieldset class="layui-elem-field">
            <legend>管理员管理 - 管理员列表</legend>
            <div class="layui-field-box">
              <!--<form class="layui-form" action="">-->
                <!--<div class="layui-form-item" style="text-align:center;">-->
                  <!--<div class="layui-inline">-->
                    <!--<div class="layui-input-inline">-->
                      <!--<input autocomplete="off" class="layui-input" placeholder="请输入名称" type="text" name="name" value="">-->
                    <!--</div>-->
                  <!--</div>-->
                  <!--<div class="layui-inline" style="text-align:left;">-->
                    <!--<div class="layui-input-inline">-->
                      <!--<button class="layui-btn"><i class="layui-icon">&#xe615;</i>查询</button>-->
                    <!--</div>-->
                  <!--</div>-->
                <!--</div>-->
              <!--</form>-->
              <!--<hr>-->
              <div class="layui-btn-group">
                  <button class="layui-btn layui-btn-xs layui-btn-normal dw-dailog" dw-url="/admin/adminAdd" dw-title="添加管理员账号" dw-width="40%" dw-height="40%">
                      <i class="layui-icon">&#xe654;</i>新增
                  </button>
                  <button class="layui-btn layui-btn-xs dw-refresh">
                      <i class="layui-icon">&#x1002;</i>刷新
                  </button>
              </div>
              <hr>
              <table class="layui-table">
                  <colgroup>
                      <col width="150">
                      <col width="150">
                      <col width="200">
                      <col>
                      <col>
                  </colgroup>
                  <thead>
                      <tr>
                      <th>管理员编号</th>
                      <th>管理员昵称</th>
                      <th>管理员密码</th>
                      <th>添加时间</th>
                      <th>管理员身份</th>
                      <th style="text-align:center;">操作</th>
                      </tr> 
                  </thead>
                  <tbody>
                  {% for adminView in result %}
                      <tr>
                      <td>{{adminView['adminId']}}</td>
                      <td>{{adminView['adminName']}}</td>
                      <td>{{adminView['adminPwd']}}</td>
                      <td>{{adminView['addTime']}}</td>
                      <td>普通管理员</td>
                      <td class="text-center">
                        <div class="layui-btn-group">
                          <button id="isBockBtn" class="layui-btn layui-btn-xs layui-btn-normal">

                              {% if adminView['isBlock'] == 1 %}
                              <span id="isBockSpan1" class="isBockSpan" isBlock="{{adminView['isBlock']}}", admin_id="{{adminView['adminId']}}"><i class="layui-icon">&#xe642;</i>取消冻结</span>
                              {% else %}
                              <span id="isBockSpan2" class="isBockSpan" isBlock="{{adminView['isBlock']}}", admin_id="{{adminView['adminId']}}"><i class="layui-icon">&#xe640;</i>冻结账号</span>
                              {% end %}

                          </button>
                        </div>
                      </td>
                      </tr>
                  {% end %}
                  </tbody>
              </table>
            </div>
        </fieldset>
    </div>
  </div>

  {% include 'temp_footer.html' %}
  <!--<div class="layui-footer">-->
    <!--&lt;!&ndash; 底部固定区域 &ndash;&gt;-->
    <!--© layui.com - 底部固定区域-->
  <!--</div>-->
</div>
<script type="text/javascript" src="{{static_url('javascript/jquery.min.js')}}"></script>
<script type="text/javascript" src="{{static_url('layui/layui.js')}}"></script>
<script type="text/javascript" src="{{static_url('icheck/icheck.js')}}"></script>
<script type="text/javascript" src="{{static_url('javascript/dw.js')}}"></script>
</body>
<script type="text/javascript">
    $('.isBockSpan').click(function () {
       var isBock = $(this).attr('isBlock');
       var adminId = $(this).attr('admin_id');

       $.ajax({
          type: 'POST',
          url: '/admin/adminIsBlock',
          data: {'is_block': isBock, 'admin_id': adminId},
          dataType: 'json',
          success: function (data) {
                if(data.result == 'ok'){
                    layer.msg('成功');

                }else{
                    layer.msg('失败');
                }
                setTimeout(function () {
                    window.location.href = window.location.href
                }, 1000);

          },
          error: function (jqXHR) {
                layer.msg('网络中断....');
          }
       });
    });
</script>
</html>